package com.xfhy.selectcity.data;

import android.app.Application;

import java.util.List;

import androidx.lifecycle.LiveData;

/**
 * @author : xfhy
 * Create time : 2021/2/25 11:23
 * Description :
 */
public class AreaRepository {

    private final AreaDao mAreaDao;

    public AreaRepository(Application application) {
        AreaRoomDatabase db = AreaRoomDatabase.getDatabase(application);
        mAreaDao = db.areaDao();
    }

    public LiveData<List<Area>> getAllAreas() {
        return mAreaDao.getAllAreas();
    }

    public LiveData<List<String>> queryCitiesByProvince(String province) {
        return mAreaDao.queryCitiesByProvince(province);
    }

    public LiveData<List<Area>> queryAreasByCity(String city) {
        return mAreaDao.queryAreasByCity(city);
    }

    public LiveData<List<String>> queryAllProvinceName() {
        return mAreaDao.queryAllProvinceName();
    }

    public LiveData<List<Area>> queryAreasByProvince(String key) {
        return mAreaDao.queryAreasByProvince(key);
    }

    public LiveData<List<Area>> searchAreasByKey(String key) {
        return mAreaDao.searchAreasByKey(key);
    }

}

